home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-05-01 | 3.4 KB | 154 lines | [TEXT/MPS ] |
- #ifndef __UTabBehaviors__
- #include <UTabBehaviors.h>
- #endif
-
- #ifndef __UEvent__
- #include <UEvent.h>
- #endif
-
- #ifndef __UApplication__
- #include <UApplication.h>
- #endif
-
- #ifndef __UWindow__
- #include <UWindow.h>
- #endif
-
- #ifndef __UMacAppUtilities__
- #include <UMacAppUtilities.h>
- #endif
-
- /////////////
- // TTabber //
- /////////////
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAOpen
-
- pascal void TTabber::Initialize()
- {
- inherited::Initialize();
- fRecursive = TRUE;
- fFoundCurrent = FALSE;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAOpen
-
- pascal void TTabber::ITabber(Boolean recursive)
- {
- this->IBehavior();
- fRecursive = recursive;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MARes
-
- pascal void TTabber::DoKeyCommand(TToolboxEvent* event)
- {
- if (event && event->fCharacter == chTab)
- this->Tab(event->fShiftKey);
- else
- inherited::DoKeyCommand(event);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MARes
-
- pascal void TTabber::Tab(Boolean tabBackward)
- {
- this->Reset();
-
- this->FindTargets();
- if (fNext == NULL)
- fNext = fFirst;
- if (fPrevious == NULL)
- fPrevious = fLast;
- if (tabBackward)
- fNext = fPrevious;
- if (fNext)
- fNext->BeTarget();
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MARes
-
- pascal void TTabber::Reset()
- {
- fFirst = NULL;
- fLast = NULL;
- fNext = NULL;
- fPrevious = NULL;
- fFoundCurrent = FALSE;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MARes
-
- pascal void TTabber::FindSubViewTargets(TView* parent)
- {
- CSubViewIterator iter(parent);
-
- for (TView* aView = iter.FirstSubView(); iter.More(); aView = iter.NextSubView())
- {
- if (aView->IsEnabled() && aView->IsShown() && aView->WantToBecomeTarget())
- {
- if (fFirst == NULL)
- fFirst = aView;
- fLast = aView;
- if (aView == gApplication->GetTarget())
- fFoundCurrent = TRUE;
- else if (fFoundCurrent && (fNext == NULL))
- fNext = aView;
- if (!fFoundCurrent)
- fPrevious = aView;
- }
- if (fRecursive)
- this->FindSubViewTargets(aView);
- }
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MARes
-
- pascal void TTabber::FindTargets()
- {
- this->SubClassResponsibility();
- }
-
- ///////////////////
- // TWindowTabber //
- ///////////////////
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MARes
-
- pascal void TWindowTabber::FindTargets() // Override
- {
- if ((qNeedsProcessMgr) || (gConfiguration.hasProcessMgr) || (!gApplication->IsDeskAccessory(FrontWindow())))
- {
- CWMgrIterator iter;
-
- for (WindowPtr aWinPtr = iter.FirstWMgrWindow(); iter.More(); aWinPtr = iter.NextWMgrWindow())
- {
- TWindow* aWindow = gApplication->WMgrToWindow(aWinPtr);
-
- if ((aWindow) && (aWindow->IsShown()) && (aWindow->IsActive()))
- this->FindSubViewTargets(aWindow);
- }
- }
-
- }
-
- /////////////////
- // TViewTabber //
- /////////////////
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MARes
-
- pascal void TViewTabber::FindTargets() // Override
- {
- this->FindSubViewTargets( (TView*) fOwner);
- }
-